import cv2 as cv
import numpy as np
import time,_thread

cap1=cv.VideoCapture(0)
cap2=cv.VideoCapture(1)
cap3=cv.VideoCapture(2)
cap4=cv.VideoCapture(3)
cap5=cv.VideoCapture(4)
cap6=cv.VideoCapture(5)
print('摄像头已打开')
#初始化摄像头
fourcc=cv.VideoWriter_fourcc(*'XVID')
out1=cv.VideoWriter('1.mp4',fourcc,20.0,(640,480))

while cap1 and cap2 and cap3 and cap4 and cap5 and cap6.isOpened():
    ret1,frame1=cap1.read()
    ret2,frame2=cap2.read()
    ret3,frame3=cap3.read()
    ret4,frame4=cap4.read()
    ret5,frame5=cap5.read()
    ret6,frame6=cap6.read()
    if not (ret1 and ret2 and ret3 and ret4 and ret5 and ret6): 
        print('摄像头读取失败')
    
def cap1_thread():
    out.write(frame1)

def cap2_thread():
    out.write(frame2)

def cap3_thread():
    out.write(frame3)

def cap4_thread():
    out.write(frame4)

def cap5_thread():
    out.write(frame5)

def cap6_thread():
    out.write(frame6)



def eye_start():
    _thread.start_new_thread(cap1_thread,())
    _thread.start_new_thread(cap2_thread,())
    _thread.start_new_thread(cap3_thread,())
    _thread.start_new_thread(cap4_thread,())
    _thread.start_new_thread(cap5_thread,())
    _thread.start_new_thread(cap6_thread,())

